package com.hackerrank.challenges.markandtoys;

import java.util.Arrays;
import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt(), K = in.nextInt(), P[] = new int[N], R = K, n = 0;
		for(int i = 0; i < N; i++)
			P[i] = in.nextInt();
		Arrays.sort(P);
		for(n = 0; n < N && R >= P[n]; n++)
			R -= P[n];
		System.out.println(n);
	}
}
